//
//  YTaskPool.h
//  mcf
//
//  Created by yuike6 yuike6 on 12-1-18.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YTask.h"

@class YFixSizeMutableDictionary;

@interface YTaskPool : NSObject<YTaskDelegate>
{
    NSOperationQueue *  _operation_queue_;
    BOOL                b_inited;
    YFixSizeMutableDictionary * taskResults;
    NSString * pool_id;
    BOOL bSetTaskPoolName;
}

@property (nonatomic, readonly) BOOL                            isInited;
@property (nonatomic, retain)   YFixSizeMutableDictionary       * taskResults;
@property (nonatomic, copy)     NSString                        * poolId;
@property (nonatomic, retain)   NSOperationQueue                * pool;

- (BOOL)        setMaxConcurrentTaskCount:(NSInteger) max_count;

- (NSString *)  addTask:(YTask *) task;
- (NSArray *)   addTasks:(NSArray *)tasks waitUntilFinished:(BOOL)wait; 

- (void)        cancelAllTask;
- (void)        cancelTask:(YTask *) task;
- (void)        cancelTaskByName :(NSString *) taskName;

- (NSInteger)   taskCount;
- (NSInteger)   maxConcurrentTaskCount;

- (void)        setSuspended:(BOOL) bSuspended;
- (BOOL)        isSuspended;

- (void)        waitUntilAllTaskAreFinished;

- (void)        stopAllTask;
- (void)        stopTask : (YTask*) task;
- (void)        stopTaskByName :(NSString *) taskName;

- (NSArray *)    tasks;

- (void)        setTaskQueuePrioity:(PriorityLevel) queuePriorityLevel withTaskName:(NSString *) taskName;

- (void)        setTaskQueuePrioity:(PriorityLevel) queuePriorityLevel withTask:(YTask *) task;

- (YTask *) taskByName:(NSString *) taskName;
@end
